Technical Field
The present invention relates to a waveform writing device, a method of writing waveforms, an electronic musical instrument that uses that device, and a storage medium.
Background Art
Some sound generators that generate musical note waveforms by writing waveform data employ a system in which in order to make it possible to use a larger number of waveforms as well as use waveform data of a greater length, unused waveform data is stored in ROM (a primary storage device), for example, and sounds are generated by transferring just the waveform data that needs to be used to RAM (a secondary storage device) which functions as waveform memory that the sound generator can access directly. This, in other words, enables a cost-effective approach in which waveform data of a size greater than the storage capacity of expensive RAM is stored in less expensive ROM, and then sounds are generated by moving waveform data only when necessary.
In this type of system, if there is insufficient space in RAM for writing a new tone waveform from ROM into RAM, a storage region in RAM to which another tone waveform is currently written must be overwritten.
One example of a technology for implementing this control process is the following (the technology is disclosed in Patent Document 1, for example). Here, the ROM stores one or more waveforms for each tone. A sound source large-scale integrated circuit (LSI) then references song data for a specified song, identifies which waveforms among the stored waveforms will be needed to emit the musical notes contained in that song data, and then reads the waveforms that were identified as necessary from ROM and transfers and stores those waveforms in RAM. This makes it possible to provide a musical note generator that can reduce the amount of waveform data that must be stored in RAM in order to generate the peak values of the musical notes that should be emitted.
Patent Document 1: Japanese Patent Application Laid-Open Publication No. 2007-271827
Meanwhile, in cases in which several waveforms are stored for each tone, each individual waveform must be stored sequentially in RAM because the loading structure of the sound source LSI typically does not allow for a single waveform to be divided up when stored in RAM. In other words, when selecting and storing data for a new tone in RAM, a free region of at least the size necessary to store the corresponding waveform sequentially must be prepared.
However, in conventional technologies, the placement of in-use waveform regions and unused regions in RAM becomes irregular as waveforms are repeatedly written and overwritten. This creates a problem in that even when tone waveforms that are currently written to RAM but are no longer needed are discarded in order to allocate free space that appears to be of sufficient size, there are cases in which new waveforms cannot be written because that free space is not sequential. For example, even if there are 10 regions of 400 kilobytes (KB) in size, a 500 KB waveform cannot be loaded. Therefore, additional tone waveforms in RAM must be sacrificed and discarded in order to be able to write a desired tone waveform. This not only results in extremely inefficient RAM usage in some cases but also makes the device more difficult to use because it becomes unclear whether or not a given tone can be written, even when the same tone waveform is already present in RAM. For example, when tones A, B, and C are currently written to RAM and then the device attempts to write a new tone D from ROM into RAM, it is unclear what needs to happen—in some cases the new tone can be written as-is, while in other cases tone A must be overwritten, and in still other cases both tones A and B must be overwritten, for example.
A similar problem occurs on general-purpose computers and the like that similarly have a primary storage device and a secondary storage device, but in these cases this problem can be solved by implementing processes such as defragmentation and garbage collection to collect all of the storage regions used by each file into a single location. Moreover, in the realm of computer devices that do not have the same requirements related to constant real time operation that musical instruments have, the user can even perform such processes manually.
However, these processes require an extremely long time to run and cannot be executed when a tone is selected on an electronic musical instrument, for example. Meanwhile, having the user manually perform such processes when the instrument is not being played creates an additional mental burden for the user and is therefore not a preferable solution for a musical instrument.
The present invention therefore aims to make it possible to reliably write a new waveform when a tone for which the corresponding waveform is not currently present in the secondary storage device is selected and a new tone waveform needs to be written from the primary storage device into the secondary storage device in order to avoid inefficient states in which the desired waveform cannot be written even though amount of free space is far greater than the size of the waveform itself. Accordingly, the present invention is directed to a scheme that substantially obviates one or more of the problems due to limitations and disadvantages of the related art.